package com.cxria.pattern.responsibilityChain

abstract class Handler {

    final static int FATHER_LVEL_REQUEST = 1
    final static int HUSBAND_LVEL_REQUEST = 2
    final static int SON_LVEL_REQUEST = 3

    private int level = 0

    Handler(int level) {
        this.level = level
    }

    Handler next

    final void handleMessage(IWomen women){
        if(women.type == level){
            response(women)
        } else {
            if(next){
                next.handleMessage(women)
            } else {
                println '---没有地方请求了,按不同意处理---\n'
            }
        }
    }

    protected abstract void response(IWomen women)

}
